import {getMusicUrl,getMusicInfo} from '@/api/api'

const SET_CHANGE = 'SET_CHANGE'
const GET_MUSIC_URL = 'GET_MUSIC_URL' //获取歌曲url
const GET_MUSIC_INFO = 'GET_MUSIC_INFO' //获取歌曲信息

const mutations={

  [SET_CHANGE](state,val){
    console.log(val);
  },

  // 获取音乐的url
  [GET_MUSIC_URL](state,id){
    getMusicUrl(id).then((res)=>{
      if(res.status == 200){
        state.music.url = res.data.data[0].url;
        // console.log(state.music);
        if(state.music.url !=""){
          state.player = false
        }
      }
    })
  },
  // 获取音乐的信息
  [GET_MUSIC_INFO](state,id){
    getMusicInfo(id).then(res=>{
      if(res.status == 200 ){
        // console.log(res.data.songs[0]);
        state.music.id = res.data.songs[0].id;
        state.music.name = res.data.songs[0].name;
        state.music.singer = res.data.songs[0].ar[0].name;
        state.music.duration = res.data.songs[0].dt;
        state.music.picUrl = res.data.songs[0].al.picUrl;
      }
    })
    // console.log(state.music);
  }











}


export default mutations;
